#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include<vector>
using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(std::string s) {

        std::vector<int> last_pos(128, -1);
        int n = s.length();
        if (n == 0) {
            return 0;
        }
        int max_len = 0;
        int left = 0;

        for (int right = 0; right < n; ++right) {

            char current_char = s[right];

            if (last_pos[current_char] >= left) {
                left = last_pos[current_char] + 1;
            }

            last_pos[current_char] = right;

            max_len = std::max(max_len, right - left + 1);
        }
        return max_len;
    }
};

int main() {
}